<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>注册</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.27.2/axios.min.js"></script>
  </head>
  <body>
    <form >
      <input type="text" />
      <input type="text" />
      <input type="submit" value="注册" />
    </form>
    <script>
      let ipts = document.querySelectorAll("input");
      ipts[2].onclick = function (evt) {
        let username = ipts[0].value;
        let password = ipts[1].value;
         console.log(password);
        let regAPI = "http://jx.xuzhixiang.top/ap/api/reg.php";

        let p = axios.get(regAPI, { params: { username: username, password } });
        p.then((r)=>{
            //成功
            console.log(r.data);
            if(r.data.code == 0){
                alert(r.data.msg);
            }else{
                alert(r.data.msg);
                location.href ="login.html"
            }
        });
        evt.preventDefault();
      };
    


    </script>
  </body>
</html>
